import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl
import pandas as pd
# 需要提前安装
# pip install pandas
# pip install openpyxl
mpl.rcParams['font.sans-serif']=['SimHei']#让中文可以正常显示
plt.rcParams['axes.unicode_minus']=False #让负号能够正常显示

data1=pd.read_excel('可视化图表.xlsx',sheet_name=1)
print(data1.head())
tel_2007=data1.iloc[:12,2]
tel_2008=data1.iloc[12:,2]
sales_2007=data1.iloc[:12,3]
sales_2008=data1.iloc[12:,3]
x_labels=data1.iloc[:12,1]
plt.figure()
plt.title('公司两年间电话次数与销量的可视化')
plt.scatter(tel_2007,sales_2007,label='2007',c='b') #c表示颜色指定，后面为颜色字母的首字母
plt.scatter(tel_2008,sales_2008,label='2008',c='r')
plt.legend()
plt.show()